#!/usr/bin/env python3
# -*- coding: utf-8 -*-

# @author: luohong
# @contact: luohong_studio@163.com
# @time: 2018/7/26
# @desc: 控制流练习 for语句，break语句

# for语句

# 输出1～3数字
print("输出1～4数字")
# rang(1,4),获取从1开始，到4结束的序列
for i in range(1,4):
    # 注意输出必须保持类型一致，str(i)转成自字符串
    print("第"+str(i)+"名")
else:
    print("=== 结束 === \n")

# 分别输出个位数是奇数和偶数
print("分别输出个位数是奇数和偶数")
oddNums = "奇数："
evenNums = "偶数："
for i in range(1,10,2):
    oddNums += str(i)+"、"
oddNums = oddNums[0:len(oddNums)-1]
print(oddNums)
for i in range(2,10,2):
    evenNums += str(i)+"、"
evenNums = evenNums[0:len(evenNums)-1]
print(evenNums)

# break 语句
# 循环1～4，当等于3时跳出循环
for i in range(1,5):
    if i == 3:
        print("=== end ===")
        break
    else:
        print(i)